<?php

if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Album_model extends MY_Model {

	var $table = 'album al';

	public function __construct() {
		parent::__construct();
	}

	public function getAlbumAll($from, $type, $source_id = '0') {
		$this->db->cache_on();
		if (!empty($source_id)) {
			$this->db->where('al.source_id', $source_id);
		}
		$query = $this->db
				->select('al.id,al.img,al.link,al.title')
				->from($this->table)
				->where(array('al.from' => $from, 'al.type' => $type))
				->get();
		$this->db->cache_off();
		$rows = $query->result_array();
		$data = array();
		if (!empty($rows)) {
			foreach ($rows as $row) {
				$row ['img'] = empty($row['img']) ? '' : base_url($row ['img']);
				$data[] = $row;
			}
		}
		return $data;
	}

}
